var app = angular.module('usersApp', []);

app.controller('usersController', function($scope) {

	var $myDlg = $('#myDlg');

	$scope.username = '';

	// $scope.saveBtnDisabled = true;

	$scope.onNewBtnClick = function() {
		$myDlg.modal('show');
	};

	$scope.saveUser = function() {

		console.log($scope.userForm)

		/*if ($scope.userForm.username.$invalid) {

			if ($scope.userForm.username.$error.minlength) {
				alert('长度必须大于等于5');
			}
			if ($scope.userForm.username.$error.maxlength) {
				alert('长度必须小于等于15');
			}
			if ($scope.userForm.username.$error.required) {
				alert('用户名不能为空');
			}
			return;

		}*/

		/*if ($scope.userForm.realname.$error.required) {
			alert('姓名不能为空');
			return;
		}

		if ($scope.userForm.realname.$error.pattern) {
			alert('姓名必须是汉字');
			return;
		}*/


		/*if ($scope.userForm.$invalid) {
			alert('请完整填写个人信息后再提交！');
			return;
		}*/

		alert('ok');

	};

	// TODO
	/*$scope.$watch($scope.userForm, function(newValue, oldValue, scope) {
		console.log($scope.userForm)
	}, true);*/

});